<?php
// Example
if (file_exists("config.xml")) {
	$config_xml = simplexml_load_file("config.xml");
} else {
	exit("Konnte Datei nicht laden. ");
}

// $quelltext = file_get_contents("http://192.168.178.1:55000/cmd=IT A 1 ON");
// Pfad für Ligthmanager setzen
$path = "/config/General/LightManager";
$LMPathXML = $config_xml -> xpath($path);
$address = $LMPathXML[0] -> URL;
$port = $LMPathXML[0] -> PORT;
$path = '/config/Actors/Actor';
$ActorsXML = $config_xml -> xpath($path);
$cmd = "";
$result = "";

$fp = fsockopen($address, (int)$port, $errno, $errstr);

if ($fp) {
	// Write command
	foreach ($ActorsXML as $Actor) {
		$action = 'OFF';

		$typ = $Actor -> Typ;
		$code = $Actor -> Code;
		$num = $Actor -> Num;
		$cmd = $cmd . $typ . ' ' . $code . ' ' . $num . ' ' . $action . '; ';

		// Finally read command prompt
	}
	echo $cmd;
	fwrite($fp, $cmd);
	fwrite($fp, "\n");
	// Return result
	echo fread($fp, 16), PHP_EOL;
	fclose($fp);
} else {
	$result = "Konnte keine Verbindung zum LM herstellen";
}
echo $result;
?>